const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const CssExtractPlugin = require('mini-css-extract-plugin')
const devMode = process.env.NODE_ENV !== 'production';

module.exports = {
    entry: './src/main.js',
    output: {
        filename: 'bundle-[hash].js',
        path: path.join(__dirname, 'dist')
    },
    module: {
        rules: [
            {
                test: /.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            },
            {
                test: /\.(js|vue)$/,
                exclude: /node_modules/,
                use: 'eslint-loader',
                enforce: 'pre',
            },
            {
                test: /.vue$/,
                use: {
                    loader: 'vue-loader',
                }
            },
            {
                test: /\.(c|le|sc|sa)ss$/,
                use: [
                    devMode ? 'style-loader' : CssExtractPlugin.loader,
                    'css-loader',
                    'less-loader'
                ]
            },
            {
                test: /\.(png|jpe?g|gif)$/,
                use: {
                  loader: 'url-loader',
                  options: {
                      esModule: false
                  }
                }
              },

        ]
    },
    plugins: [
        new VueLoaderPlugin(),
        new CssExtractPlugin()
      ]
}